//
//  ReadFooterView.m
//  WNZSSQ
//
//  Created by JDKJ on 2018/12/7.
//  Copyright © 2018年 JDKJ. All rights reserved.
//

#import "ReadFooterView.h"

@implementation ReadFooterView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = CSColorFromRGB(0x333333);
        
        /**
         目录
         */
        UIButton *listBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [listBtn setImage:[UIImage imageNamed:@"icon_list"] forState:UIControlStateNormal];
        [listBtn setTitle:@"目录" forState:UIControlStateNormal];
        [listBtn setTitleColor:CSColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
        listBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:listBtn];
        self.listBtn = listBtn;
        
        /**
         设置
         */
        UIButton *setBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [setBtn setImage:[UIImage imageNamed:@"设置"] forState:UIControlStateNormal];
        [setBtn setTitle:@"设置" forState:UIControlStateNormal];
        [setBtn setTitleColor:CSColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
        setBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:setBtn];
        self.setBtn = setBtn;
        
        /**
         白天黑夜
         */
        UIButton *nightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [nightBtn setImage:[UIImage imageNamed:@"read_default"] forState:UIControlStateSelected];
        [nightBtn setImage:[UIImage imageNamed:@"read_night"] forState:UIControlStateNormal];
        [nightBtn setTitle:@"黑夜" forState:UIControlStateNormal];
        [nightBtn setTitle:@"白天" forState:UIControlStateSelected];
        [nightBtn setTitleColor:CSColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
        nightBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:nightBtn];
        self.nightBtn = nightBtn;
        if ([LSYReadConfig shareInstance].theme == CSWhiteColor) {
            
            self.nightBtn.selected = NO;
            
        }else
        {
            self.nightBtn.selected = YES;
        }
        
        /**
         下载
         */
        UIButton *loadDownBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [loadDownBtn setImage:[UIImage imageNamed:@"下载"] forState:UIControlStateNormal];
        [loadDownBtn setTitle:@"下载" forState:UIControlStateNormal];
        [loadDownBtn setTitleColor:CSColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
        loadDownBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:loadDownBtn];
        self.loadDownBtn = loadDownBtn;
        
        [self setConstraints];
        
    }
    return self;
    
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     目录
     */
    [self.listBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.mas_equalTo(self);
        make.width.mas_equalTo(SCREENWIDTH/4);
        make.height.mas_equalTo(49);
        
    }];
    
    /**
     设置
     */
    [self.setBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self);
        make.left.mas_equalTo(self.listBtn.mas_right);
        make.width.height.mas_equalTo(self.listBtn);
        
    }];
    
    /**
     白天黑夜
     */
    [self.nightBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self);
        make.left.mas_equalTo(self.setBtn.mas_right);
        make.width.height.mas_equalTo(self.listBtn);
        
    }];
    
    /**
     下载
     */
    [self.loadDownBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self);
        make.left.mas_equalTo(self.nightBtn.mas_right);
        make.width.height.mas_equalTo(self.listBtn);
        
    }];
    
    
}


-(void)layoutSubviews
{
    [self.listBtn titleBelowTheImageWithSpace:5];
    [self.setBtn titleBelowTheImageWithSpace:5];
    [self.nightBtn titleBelowTheImageWithSpace:5];
    [self.loadDownBtn titleBelowTheImageWithSpace:5];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
